package com.tienon.message.Test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.annotation.Resource;

import org.junit.Test;
import org.springframework.stereotype.Component;

import com.tienon.message.thread.LoadRawMsgItemThread;
import com.tienon.message.thread.task.ReLoadRawMsgItemTask;

@Component
public class Raw_Msg_ItemReSendTest extends UnitTestEnv {
	
	@Resource
	private ReLoadRawMsgItemTask loadRawMsgItemTask;
	
	/**
	 * 测试消息接入重试线程
	 * @throws InterruptedException
	 */
	@Test
	public void reSendTest() throws InterruptedException{
		 ExecutorService executor = Executors.newFixedThreadPool(4);//启动线程池,线程池大小为10
		    for(int i = 0;i < 4;i++){
		    	Runnable raw_msg_item = new Thread(new LoadRawMsgItemThread(loadRawMsgItemTask));
		    	System.err.println(raw_msg_item);
		    	executor.execute(raw_msg_item);
		    }
		    while(true){
		    	if(!executor.isTerminated()){
		    		Thread.sleep(100);
		    	}
		    }
	}
}
